package cn;

import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.catalina.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.Sha1Hash;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.apache.shiro.crypto.hash.Sha512Hash;
import org.apache.shiro.subject.Subject;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

import cn.dliyy.file.CsvUtil;
import cn.dliyy.warehouse.bean.BUnit;
import cn.dliyy.warehouse.dao.EntityDaoImpl;

public class Test {

  /**
   * @param args
   */
  public static void main(String[] args) {
    CsvUtil cu = new CsvUtil("E:\\SSS.csv");
    File f = new File("E:\\life.xml");
    Element t ;
    for (int i = 0; i < cu.getRowNum(); i++) {
      
      
      
      cg.setCountryCode(cu.getString(i, 0));
      cg.setRegionCode(cu.getString(i, 1));
      cg.setRegionName(cu.getString(i, 2));
      entityDao.save(cg);
    }
   
    /*
     * BUnit bunit = new BUnit();
     * System.out.println(BUnit.class.getSimpleName());
     * System.out.println(bunit.getClass().getSimpleName()); Object o= bunit;
     * System.out.println(o.getClass().getSimpleName());
     * 
     * 
     * EntityDaoImpl dao = new EntityDaoImpl();
     */

  }

  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) {
    UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
    AuthenticationToken atoken;
    Subject cuser;
    SecurityUtils su;
    User user;

    return null;

  }
  
  private void read(){
    SAXBuilder builder = new SAXBuilder();
    File f = new File("E:\\life.xml");
    StringBuffer sb = new StringBuffer();
    try {
      Document doc = builder.build(f);
      Element root = doc.getRootElement();
      Element efd=root.getChild("FormConfig");
      List<Element> tlist = efd.getChildren();
      for (Element e : tlist) {
        e.getAttributeValue("name");
       // System.out.println(e.getAttributeValue("name"));
        sb.append(e.getAttributeValue("name"));
        sb.append(",");
        sb.append(e.getChildText("X"));
        sb.append(",");
        sb.append(e.getChildText("Y"));
        sb.append(",");
        sb.append(e.getChildText("Font"));
        sb.append(",");
        sb.append(e.getChildText("Size"));
        sb.append("\n");

      }
      System.out.println(sb.toString());

    } catch (JDOMException e1) {
      System.out.println("sms.xml 文件读取错误");
    }
  }
  
  private void date(){
    Calendar c = Calendar.getInstance();
    c.set(2012, 5, 20, 19, 30, 0);
    System.out.println(c.getTime());
    Date date1 = new Date(System.currentTimeMillis());
    
    System.out.println("date "+new Date());
    System.out.println("calendar "+date1);
    System.out.println("systemtime "+Calendar.getInstance().getTime());

    int date = c.get(Calendar.DATE);
    int m = c.get(Calendar.MONTH);
    System.out.println(m + "-" + date);
  }

  private void t() {
    int i = 0xf;
    int k = 0x7;
    System.out.println(i & k);
    System.out.println(i ^ k);
    System.out.println(i | k);
    char[] c = "ttt我们".toCharArray();
    System.out.println(c.length + ";" + Character.SIZE);
    String a = "";

    String encodedPassword1 = new Sha1Hash("1第三").toBase64();
    String encodedPassword3 = new Md5Hash("1第三").toString();
    String encodedPassword4 = new Md5Hash("1第三").toHex();
    String encodedPassword5 = new Md5Hash("1第三").toBase64();
    String encodedPassword2 = new Sha256Hash("q").toBase64();
    System.out.println(encodedPassword1 + ":" + encodedPassword1.length());
    System.out.println(encodedPassword2 + ":" + encodedPassword2.length());
    System.out.println(encodedPassword3 + ":" + encodedPassword3.length());
    System.out.println(encodedPassword4 + ":" + encodedPassword4.length());
    System.out.println(encodedPassword5 + ":" + encodedPassword5.length());
  }

}
